package com.husky.diyservice.service.impl;


import com.husky.diyservice.common.ChannelProxyDispatchFactory;
import com.husky.diyservice.common.service.ChannelProxyService;
import com.husky.diyservice.service.WebService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
 * @Author husky
 * @Date 2022/12/14 16:48
 * @Description:
 **/
@Service
@Slf4j
public class WebServiceImpl implements WebService {

    /**
     * 代理工厂
     */
    @Autowired
    private ChannelProxyDispatchFactory<ChannelProxyService> channelProxyService;

    /**
     * 插入日志
     * @param channelType 代理约定日志类型 1.足迹 2.埋点 3.管理端操作 4.mq留痕
     */
    @Override
    public void insertLogs(String channelType) {
        try {
            // 获取代理接口实现，并执行相应的方法
            ChannelProxyService service = channelProxyService.getService(channelType);
            if(!ObjectUtils.isEmpty(service)){
                service.insertLogs();
            }
        }catch (Exception e){
            log.error(" 获取代理接口异常。Exception={}",e);
        }

    }
}
